import { fileURLToPath, URL } from 'url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
    plugins: [
        vue(),
    ],
    base: './',
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server: {
        open: true,
        port: 5000,
        host: '0.0.0.0',
        hmr: true,
        proxy: {
            '/api': {
                // target: 'https://www.oceanread.net:1102',
                target: 'http://localhost:1102',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
            '/go': {
                // target: 'https://www.oceanread.net:1102',
                target: 'http://localhost:1102',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/go/, '')
            },
            '/sm': {
                target: 'http://192.168.0.133:8080',
                // target: 'http://192.168.0.133:8080',
                // target: 'http://59.110.0.27:1102/public/img/',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/sm/, '')
            },
            '/qs': {
                target: 'http://localhost:1009',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/qs/, '')
            },
            '/floating': {
                target: 'https://xxs.dhybzx.org:3000/qsxcx/floating/',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/qs/, '')
            },
            '/dalian': {
                target: 'http://gg.oceanread.com:1051/dingding',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/dalian/, '')
            },
        },
    },
    build: {
        chunkSizeWarningLimit: 20000
    },
})
